<template>
	<view class="big-box flex-col align-center">
		<top-navigation bgColor='#FFFFFF00' :isBack="true">
			<text slot='center-slot' class="center-slot">实名认证</text>
			<!-- <text slot='right-slot' class="right-slot">完成</text> -->
		</top-navigation>
		<u-toast ref="uToast"></u-toast>

		<!-- 我的baby -->
		<view class="" style="height: 40rpx;">

		</view>
		<view class="label justify-start">
			真实姓名
		</view>
		<view class="top-box">
			<view class="top-cell justify-between align-center">
				<u-input v-model="realname" color='#FFF' border="none" clearable placeholder="请输入您的真实姓名"></u-input>
			</view>
		</view>
		<view class="label justify-start">
			身份证号
		</view>
		<view class="top-box">
			<view class="top-cell justify-between align-center">
				<u-input v-model="idcard" type="text"
				 maxlength='18'
				 color='#FFF' border="none" clearable placeholder="请输入18位身份证号"></u-input>
			</view>
		</view>
		<view class="tips justify-start">
			为了您的资产安全，需要认证你的真实身份信息。你提供的真实身份信息将受到严格保护，不会用于其他用途，请你放心填写。
			<br />
			使用真实姓名及有效身份证号进行实名；
			<br />
			身份信息提交后不可进行修改;有意填写非本人身份信息者，被发现将对账号进行封禁处理；
		</view>

		<view class="btn justify-center align-center" @tap="submit"
		:style="{background: disable?'#8E929D':'#27ff92'}"
		
		>
			完成
		</view>

		<!-- 联系客服弹出层-->
		<u-popup :show="moneyShow" mode="center" @close="moneyShow=false" round="16rpx" bgColor='transparent'
			overlayOpacity='0.7'>
			<view class="popup-one-box flex-col align-center">

				<view class="has-shuijing justify-center">
					实名认证后即可使用本功能
				</view>
				<view class=" justify-between">
					<view class="popup-box-btn align-center justify-center" @click="moneyShow=false">
						取消
					</view>
					<view class="popup-box-btn-1 align-center justify-center"
						@click="$navto('/pages/mine/setting/userRealName')">
						去实名
					</view>
				</view>


			</view>
		</u-popup>
		<message-modal :isShow='captchaShow' @sendMobileCode='submit' @close='captchaShow=false'></message-modal>
	</view>
</template>

<script>
	import {
		geTel
	} from '@/utils/libs.js'
	import messageModal from './messageModal/messageModal.vue'
	export default {
		components: {
			messageModal
		},
		data() {
			return {
				captchaShow: false,
				current: 0,
				realname: '',
				idcard: '',
				form: {
					mobile: null, //	否	string	手机号
					smscode: null, //	否	string	短信码
					nickname: null, //	否	string	昵称
					airline_id: null, //	否	string	航司ID
					position: null, //	否	string	职务
					identity: null, //	否	string	证件照
					name: null, //	否	string	证件照
					gender: '请选择',

				},
				genderIsShow: false,
				genderList: [
					['男', '女']
				],
				moneyShow: false,
				realName: false, //是否实名
				update: false,
				userInfo: {},
				navt: '',

			}
		},
		onLoad(o) {
			if (o.type == 'payPass') {
				this.navt = 'payPass'
			}
			if (o.type == 'myOre') {
				this.navt = 'myOre'
			}
		},
		computed: {
			disable() {
				return !(this.idcard.length==18&&this.realname)
			}
		},
		methods: {
			geTel, //手机号脱敏

			async submit(e ) {
				if (this.disable) return
				if (e && e.captcha) {

				} else {
					this.captchaShow = true
					return
				}
				let _this = this
				let url = '/api/v1/authentication'
				let {
					code,
					msg,
					data
				} = await this.$postRequest(url, {
					realname: this.realname,
					idcard: this.idcard,
					captcha: e.captcha,
					rand_id: e.id
				})
				if (code == 200) {
					await this.getCardInfo()
					this.$refs.uToast.show({
						message: msg,
						complete() {
							if (_this.navt == 'payPass') {
								_this.$navto('/pages/mine/setting/payPass/payPass', false, 5)
							} else if (_this.navt == 'myOre') {
								const value = uni.getStorageSync('userInfo')
								if (value.is_pay_password == 0) {
									_this.$navto('/pages/mine/setting/payPass/payPass?type=myOre', false, 5)
								} else {
									_this.$navto('/pages/mine/myOre/myOre', false, 5)
								}
							} else {
								const value = uni.getStorageSync('userInfo')
								if (value.is_pay_password == 0) {
									_this.$navto('/pages/mine/setting/payPass/payPass', false, 5)
								} else {
									_this.$navto('/pages/mine/setting/setting', false, 5)
								}
							}
						}
					})
				} else {
					this.$refs.uToast.show({
						message: msg
					})
				}
			},
			async getCardInfo() {
				let url = '/api/v1/my'
				let {
					code,
					msg,
					data
				} = await this.$getRequest(url)
				if (code == 200) {
					console.log(data, '静态资源');
					uni.setStorageSync('userInfo', data[0])
					this.userInfo = data[0]
				} else {
					this.$refs.uToast.show({
						message: msg
					})
				}
			},
			genderConfirm(e) {
				// this.form.gender = e.value[0]
				this.form.gender = e.value[0] == '男' ? '1' : '2'
				this.genderIsShow = false
				console.log(e.value[0]);
			},
			myCopy(value) {
				let _this = this
				//提示模板
				uni.setClipboardData({
					data: value, //要被复制的内容
					showToast: false,
					success: () => { //复制成功的回调函数
						_this.$refs.uToast.show({
							message: '已复制',
							type: 'default',
							duration: '500'

						})
						// uni.showToast({ //提示
						// 	title: wxorqq == 'w' ? "微信号已复制" : 'QQ号已复制'
						// })
					}
				});
			},
			setCategory(value) {
				switch (value) {
					case 1:
						// 支付密码
						if (this.realName) {

						} else {
							this.moneyShow = true
						}
						break;
					default:
						break;
				}
			},
			bannerChange() {
				// banner改变
			},
			featureTap(e) {
				this.moneyShow = true
			}
		}
	}
</script>
<style>
	@import '/common/css/common.css';
</style>
<style lang="scss" scoped>
	.big-box {
		background: linear-gradient(180deg, #152435 0%, #16161E 100%);
		padding: 0 48rpx 60rpx;
		min-height: 100vh;

		.label {
			margin-top: 15rpx;
			width: 100%;
			font-size: .875rem;
			color: rgba(255, 255, 255, .6);
			padding: 0 0 .75rem;
		}

		.center-slot {
			color: #FFF;
		}

		.right-slot {
			font-size: .8125rem;
			color: #27ff92;
		}



	}

	.btn {
		left: 50%;
		transform: translate(-50%, 0);
		right: 0;
		position: fixed;
		height: 90rpx;
		width: calc(100vw - 96rpx);
		border-radius: 8rpx;
		bottom: 45rpx;
		font-weight: 700;
		font-size: 30rpx;
		background-color: #27FF92;
		;
		color: #000;
	}

	.tips {
		margin-top: 1.46875rem;
		font-size: .75rem;
		line-height: 1.125rem;
		color: rgba(255, 255, 255, .6);
	}

	.top-box {
		width: 100%;
		position: relative;
		margin: 0rpx auto 0rpx;
		padding: 0rpx 32rpx;
		background-color: #20202c;
		border-radius: 16rpx;

		.top-cell {
			background: #20202c;
			min-height: 120rpx;
			padding: 20rpx 0;
			color: #FFF;

			.name {
				margin-right: 30rpx;
				font-size: 28rpx;
				color: rgba(255, 255, 255, .8);

			}

			.ava {
				width: 96rpx;
				height: 96rpx;
				border-radius: 8rpx;
			}
		}


		.my-qing-long {
			font-size: 28rpx;
			width: 260rpx;
			color: rgba(255, 255, 255, .8);
			text-align: left;
		}

		.long-num {
			width: 30rpx;
			height: 30rpx;

		}
	}

	.feature-app {
		height: 400rpx;
		width: 100%;
		padding: 46rpx 32rpx 0;
		margin-bottom: 24rpx;
		box-sizing: border-box;
		background-color: #20202c;
		border-radius: 16rpx;

		.set-name {
			font-size: 28rpx;
			color: #FFF;
		}

		.jiantou {
			width: 30rpx;
			height: 30rpx;
		}

		.feature-box-app {
			margin: 32rpx 0 32rpx;
			width: 155rpx;

			.open-map-icon {
				width: 48rpx;
				height: 48rpx;
				margin-bottom: 22rpx;
			}

			.title-order {
				font-size: 24rpx;
				color: #FFFFFFCC;
			}
		}

	}


	.popup-one-box {
		position: relative;
		z-index: 7;
		width: 560rpx;
		border-radius: 16rpx;
		background: #1D1D1D;
		padding: 48rpx 40rpx;

		.has-shuijing {
			width: 100%;
			height: 44rpx;
			font-size: 32rpx;
			color: #FFFFFF;
			margin-bottom: 48rpx;
		}

		.shui-ji-num {
			font-size: 28rpx;
			color: #FFF;
			font-weight: 700;
		}

		.popup-box-btn {
			width: 227rpx;
			height: 72rpx;
			background: #252727;
			color: rgba(255, 255, 255, .4);
			font-size: 28rpx;
			border-radius: 8rpx;
		}

		.popup-box-btn-1 {
			width: 227rpx;
			height: 72rpx;
			background: #27FF92;
			color: #000;
			font-size: 28rpx;
			margin-left: 24rpx;
			border-radius: 8rpx;
		}




		.popup-kuangshi {
			width: 56rpx;
			height: 36rpx;
		}







	}
</style>